package io.adrainty.bolee.task.stream;

import io.adrainty.bolee.framework.commons.basic.ResultDTO;
import io.adrainty.bolee.framework.commons.utils.ResultDTOUtil;
import io.adrainty.bolee.framework.mq.basic.MQMessage;
import io.adrainty.bolee.framework.mq.basic.MQMessageType;
import io.adrainty.bolee.framework.mq.stream.BaseStreamHandler;
import io.adrainty.bolee.insurance.feign.IWarrantyFeign;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

/**
 * <p>WarrantyMsgConsumer</p>
 *
 * @author AdRainty
 * @version V1.0.0
 * @description 保费消息
 * @since 2025/8/26 13:48:57
 */

@Component(value = "warrantyChannel")
public class WarrantyMsgConsumer extends BaseStreamHandler {

    @Resource
    private IWarrantyFeign warrantyFeign;

    @Override
    public void doConsume(MQMessage message) {
        String warrantyNo = message.getContent();
        ResultDTO<Boolean> resultDTO = warrantyFeign.cleanWarranty(warrantyNo);
        ResultDTOUtil.assertResultSuccess(resultDTO);
    }

    @Override
    public MQMessageType acceptMsgType() {
        return MQMessageType.WARRANTY_MESSAGE;
    }

}
